local jinggou = fk.CreateSkill{
  name = "rfenghou_3d11j__jinggou",
  tags = { Skill.Compulsory }
}

jinggou:addEffect(fk.CardUseFinished, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(jinggou.name) and data.card and data.card.sub_type == Card.SubtypeWeapon then
      local others = table.map(player.room:getOtherPlayers(player, false), function(other) return other:getAttackRange() end)
      local range = player:getAttackRange()
      local lt, gt = true, true
      for _, other in ipairs(others) do
        if lt and range > other then
          lt = false
        elseif gt and range < other then
          gt = false
        elseif not (lt or gt) then
          return false
        end
      end
      return lt or gt
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:askToChoosePlayers(player, {
      targets = room:getAlivePlayers(false),
      min_num = 1,
      max_num = 1,
      skill_name = jinggou.name,
      prompt = "#rfenghou_3d11j__jinggou-damage",
      cancelable = false
    })[1]
    if to ~= nil then
      room:damage{
        from = player,
        to = to,
        damage = 1,
        skillName = jinggou.name
      }
    end
  end
})

Fk:loadTranslationTable{
  ["rfenghou_3d11j__jinggou"] = "精彀",
  [":rfenghou_3d11j__jinggou"] = "锁定技，你使用的武器牌结算后，若你的攻击范围为全场最大或最小（或之一），你须对一名角色造成1点伤害。",

  ["#rfenghou_3d11j__jinggou-damage"] = "精彀：你须对一名角色造成1点伤害！",
}

return jinggou
